Skip to main content

Request to server

Sending encrypted 'Report Ghosting' data to the server ensures the secure delivery of sensitive information. This section outlines the process of transmitting the encrypted data using HTTP requests.

tip

Ensure your API endpoint is correctly configured to handle the incoming encrypted data.

Data Transmission Process

The data transmission process involves a few key steps:

  1. Prepare the Encrypted Data: Use the previously encrypted data and format it for transmission.

  2. Set Up the Payload: Include the encrypted data and any required subscription keys in the payload.

  3. Send the Data: Use an HTTP POST request to send the payload to the server.

Example Code :

Example JSON Object:

// Function to send encrypted data
function sendEncryptedData(encryptedData, apiUrl, subscriptionKey) {
const payload = {
encryptedData: encryptedData,
subscriptionKey: subscriptionKey
};

fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
}).then(response => response.json())
.then(data => {
console.log("Debug: Response Status Code:", data);

if (data.message) {
console.log("API Message:", data.message);
} else {
console.log("No 'message' field in response.");
}
}).catch(error => {
console.error("Error occurred:", error.message);
});
}

// Test Data
const testData = {
email: "ADD_EMAIL",
governmentId: "ADD_GOVERNMENT_ID",
governmentIdType: "ADD_GOVERNMENT_TYPE_ID",
jobObject: {
jobSkills: "ADD_JOB_SKILLS",
jobRole: "ADD_JOB_ROLE",
employmentType: "ADD_EMPLOYMENT_TYPE",
ghostedReasonByCompany: "GHOSTING_REASON"
}
};

const encryptedData = "ADD_YOUR_PLUGIN_KEY";
const subscriptionKey = "ADD_YOUR_SUBSCRIPTION_KEY;
const apiUrl = "ADD_YOUR_API_URL";

try {
console.log("Starting Encryption Process");
const encryptedResult = encryptData(testData, encryptedData);

console.log("Sending Encrypted Data to API");
sendEncryptedData(encryptedResult, apiUrl, subscriptionKey);
} catch (e) {
console.error("An error occurred:", e.message);
}

Steps for Data Transmission:

  1. Encrypt the Data: Ensure the data is encrypted before transmission.

  2. Prepare the Payload: Construct the payload with the encrypted data and subscription key.

  3. Send the Data: Use an HTTP POST request to send the encrypted data to the API endpoint.

Example Payload::

{
"encryptedData": "base64_encoded_encrypted_data",
"subscriptionKey": "your_subscription_key"
}
warning

Always validate the server's response and handle any errors appropriately to ensure the security and reliability of your data transmission process.